<!-- 修改密码-->
<template>
	<view>
		<view class="all content">
			<view class="all-item">
				<view class="all-name">{{inter.oldPassword}}：</view><input type="password" v-model="oldpwd" placeholder-class="pla-style" :placeholder="inter.placeholderOld"  class="username" value="" />
			</view>
			<view class="all-item">
				<view class="all-name">{{inter.newPassword}}：</view><input type="password" v-model="password" placeholder-class="pla-style" :placeholder="inter.placeholderNew"  class="username" value="" />
			</view>
			<view class="all-item2">
				<view class="all-name">{{inter.reNewPassword}}：</view><input type="password" v-model="repwd" placeholder-class="pla-style" :placeholder="inter.placeholderReNew"  class="username" value="" />
			</view>
		</view>
		<view style="display: flex;align-items: center; justify-content: center;">
			<div class="sub-button" @click="modify">
				<image  src="../../static/DMS_djrw_tj_icon.png" style="width: 40upx;height: 40upx;margin-right: 18upx;" mode="scaleToFill"></image>
				<text style="font-size:32upx;color:#FFFFFF">{{inter.save}}</text>
			</div>
		</view>
		
	</view>
</template>

<script>
	import $api from '@/api/api.js'
	import $inter from '@/api/international.js'
	export default{
		data(){
			return{
				languageValue:'',
				internatinal:'',
				oldpwd:"",
				password:"",
				repwd:"",
				
			}
		},
		onLoad() {
			uni.getStorage({
				key:'languageValue',
				success:(res)=>{
					this.languageValue = res.data
				}
			})
			uni.setNavigationBarTitle({
				title: this.inter.czmm
			});
		},
		methods: {
			
			modify(){
				//console.log(this.baseURL+"++++++++"+this.token);
				if(this.oldpwd =="" || this.oldpwd ==undefined){
					uni.showToast({
						title: this.inter.oldPasswordTips,
						icon:"none",
						duration: 3000
					});
					return ;
				}
				if(this.password =="" || this.password ==undefined){
					uni.showToast({
						title: this.inter.newPasswordTips,
						icon:"none",
						duration: 3000
					});
					return ;
				}
				if(!(this.repwd == this.password)){ 
					uni.showToast({
						title: this.inter.reNewPasswordTips,
						icon:"none",
						duration: 3000
					});
					return ;
				}
				uni.showLoading({title: 'Loading...'});
				console.log( "密码"+this.oldpwd+"==="+this.password);
				let parmas = {
						OldPsd: this.oldpwd,
						NewPsd:this.password
					}
				$api.changePassword(parmas,res=>{
						if (res.success==true) {
							$api.idSetter('Authorization_Token','')
							$api.idSetter('password','')
							uni.reLaunch({
								url: '../login/login'
							});
							
							uni.showToast({
								title: this.inter.successTips,
								icon:"none",
								duration: 2000
							});
						} else{
							uni.showToast({
								title: this.inter.failTips,
								icon:"none",
								duration: 2000
							});
						}
						uni.hideLoading();
					},err=>{
						uni.hideLoading();
						console.log(err);
					},e=>{
						console.log(e);
					})
					
			}
		},
		computed: {
			inter(){
				return $inter.my
			}
		},
	}
</script>

<style>
	.content{
		margin-top: 40upx;
	}
	.all{
		display: flex;
		align-items: center;
		flex-direction: column;
		background-color: #FFFFFF;
	}
	.all-item{
		width: 700upx;
		height: 100upx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		border-bottom: 1upx solid #d7d3d3;
		font-size: 28upx;
	}
	.all-item2{
		width: 700upx;
		height: 100upx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		font-size: 28upx;
	}
	.username{
		width: 100%;
		display: block;
	}
	.all-name{
		width: 350upx;
	}
	.sub-button{
		display: flex;
		flex-direction: row;
		margin-top: 200upx;
		width:596upx;
		height:80upx;
		background: -webkit-linear-gradient(left, #107FD2 , #06C9ED); /* Safari 5.1 - 6.0 */
		background: -o-linear-gradient(right, #107FD2, #06C9ED); /* Opera 11.1 - 12.0 */
		background: -moz-linear-gradient(right, #107FD2, #06C9ED); /* Firefox 3.6 - 15 */
		background: linear-gradient(to right, #107FD2 , #06C9ED); /* 标准的语法 */
		border-radius:8upx;
		justify-content: center;
		align-items: center;
		
	}
	.pla-style{
		font-size: 28upx;
		color: #d7d3d3;
	}
</style>
